package com.chenfeng.ego.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chenfeng.ego.commons.pojo.EasyUiTree;
import com.chenfeng.ego.commons.pojo.EgoResult;
import com.chenfeng.ego.service.TbContentCatgroyService;

@Controller
public class TbContentCategory
{

	@Resource
	TbContentCatgroyService catgroyService;
	@RequestMapping("content/category/list")
	@ResponseBody
	//商品内容管理树型表
	public List<EasyUiTree> showCategory(@RequestParam(defaultValue="0") long id)
	{
		System.out.println(id);
		return this.catgroyService.selById(id);
	}
	@RequestMapping("content/category/create")
	@ResponseBody
	//增加内容分类传递过来的是parentId  插入的时候先把插入的节点变成子节点可显示   再把父节点都变成true 因为不管他是true还是不是一旦插入新的节点之后他总是true
	public EgoResult createCatgeroy(long parentId,String name)
	{
		return this.catgroyService.insertByid(parentId, name);
	}
	//商品删除的操作
	@RequestMapping("content/category/delete")
	@ResponseBody
	public EgoResult deleteCategeroy(long id)
	{
		return this.catgroyService.deleteByid(id);
	}
	
}
